package com.example.demo.order.rocketmq.producer;

import com.example.demo.order.entity.Order;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;

import jakarta.annotation.Resource;

/**
 * @ClassName OrderProducer
 * @Description 消息生产者
 * @Author MingChang.Wei
 * @Date 2025/8/8
 **/
@Component
public class OrderProducer {

    @Resource
    private RocketMQTemplate rocketMQTemplate;

    public void sendCreateOrderMessage(Order order) {
        rocketMQTemplate.convertAndSend("order_create_topic", order.toString());
    }

    public void sendPayOrderMessage(String orderNo) {
        rocketMQTemplate.convertAndSend("order_pay_topic", orderNo);
    }

    public void sendRefundOrderMessage(String orderNo) {
        rocketMQTemplate.convertAndSend("order_refund_topic", orderNo);
    }
}
